$(function (){
	var dbid = $('._cdb_id').val();
	//数据判断

	//ajax提交
	$('._next_submit').click(function (){
		var data = getdata();
//		console.log(data);

		$.ajax({
		    url:'/Structure/connectdb.html',
		      type:'POST',
		      dataType:'json',
		      async:true,
		      data:data,
		      success:function (req){
		        if(req.status==200){
		        	if(dbid!='' || dbid!='undefined'){
		        		location.href="/Structure/index.html?type=1";
		        	}else{
		        		location.href="/Structure/selectdbtable.html?id="+req.data;		
		        	}
		          
		        }else{
		          alert(req.msg);
		        }
		        return;
		      }
		  });
	});

});

function getdata(){
	var ip = $('._db_ip').val();
	var port = $('._db_port').val();
	var dbname = $('._db_dbname').val();
	var account = $('._db_account').val();
	var pwd = $('._db_pwd').val();
	var dbid = $('._cdb_id').val();

	//判断是否为空

	//有错误时不能提交

	var data = {};
	data.ip = ip;
	data.port = port;
	data.dbname = dbname;
	data.account = account;
	data.pwd = pwd;
	data.dbid = dbid;
	return data;

}

